package cn.tedu.file;

import java.io.*;
import java.util.Scanner;

public class IOUitls {
    /*
    这个方法用来完成文件复制
     */
    public static void copyOf(String frompath, String topath) {
        InputStream in = null;
        OutputStream ou = null;
        try {
            in = new BufferedInputStream(new FileInputStream(frompath));
            ou = new BufferedOutputStream(new FileOutputStream(topath));
            //边读边写
            int b = 0;
            while ((b = in.read()) != -1) {
                ou.write(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                ou.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}



//    //创建方法，1求大小
//    public static long totalSize(File dir){
//        File []fs =dir.listFiles();
//        long sum = 0;
//        for (int i = 0; i <fs.length ; i++) {
//            if(fs[i].isFile()){
//                sum = sum+fs[i].length();
//            }
//            else if(fs[i].isDirectory()){
//                sum = sum+totalSize(fs[i]);
//            }
//        }
//        return sum;
//    }
//    public static void totalDelete(File dir){
//        File []fs =dir.listFiles();
//        for (int i = 0; i <fs.length; i++) {
//            if(fs[i].isFile()){
//                fs[i].delete();
//            }else if(fs[i].isDirectory() ){
//                totalDelete(fs[i]);
//            }
//        }
//        dir.delete();
//    }
//}

